using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;

using Deepcode.Flux.Core.Data;
using Deepcode.Flux.Core.Systems.Workflow.Enums;

namespace Deepcode.Flux.Core.Systems.Workflow.Bases
{
	/// <summary>
	/// Represents an exit action to execute on an exit path
	/// </summary>
	public class ExitAction
	{
		// Private fields for storing record fields //
		private int					_PK_ID = -1;
		private int					_FK_ExitPathID = -1;
		private int					_Rank = -1;
		private string				_Method = "";
		private string				_PropertyBag = "";

		// Public fields exposing record fields //
		public int PK_ID { get { return _PK_ID; } set { _PK_ID = value; } }
		public int FK_ExitPathID{ get{ return _FK_ExitPathID; } set{ _FK_ExitPathID = value; }}
		public int Rank{ get{ return _Rank; } set{ _Rank = value; }}
		public string Method{get{return _Method;}set{_Method=value; }}
		public string PropertyBag { get{ return _PropertyBag; } set{ _PropertyBag=value; }}
		
		// Link backs
		public TaskExitPath ParentExitPath { get { return new TaskExitPaths().GetTaskExitPathByID(this.FK_ExitPathID); } }

		// Constructor to create new without loading
		public ExitAction () { }

		// Constructor loading from a data row
		public ExitAction(DataRow InitFromRow)
		{
			_PK_ID = SQLUtility.DBNull(InitFromRow["PK_ID"], -1);
			_FK_ExitPathID = SQLUtility.DBNull(InitFromRow["FK_ExitPathID"], -1);
			_Rank = SQLUtility.DBNull(InitFromRow["Rank"], -1);
			_Method = SQLUtility.DBNull(InitFromRow["Method"], "");
			_PropertyBag = SQLUtility.DBNull(InitFromRow["PropertyBag"], "");
		}
	}
}
